<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>商城购物车界面</title>
    <link rel="stylesheet" type="text/css" href="css/public.css"/>
    <link rel="stylesheet" type="text/css" href="css/carts.css"/>
    <script src="js/jquery-3.6.0.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/cart.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="head">
    <div class="shouye_head">
        <a href="first.jsp">商城首页</a>
    </div>
</div>
<div class="cart">
    <div class="cart-head">
        <div class="column g-select">
            <div class="g-checkbox">
                <input type="checkbox" class="all each">
            </div>
            全选
        </div>
        <div class="column g-images">图片</div>
        <div class="column g-goodsname">商品名称</div>
        <div class="column g-price">单价</div>
        <div class="column g-quantity">数量</div>
        <div class="column g-sum">小计</div>
        <div class="column g-action">操作</div>
    </div>
    <c:if test="${empty sessionScope.carList}">
        <div class="cart-empty">购物车为空</div>
    </c:if>
    <c:forEach items="${sessionScope.carList}" var="item">

        <div class="carts-goods">
            <div class="cell c-select">
                <div class="c-checkbox">
                    <input type="checkbox" class="each">
                </div>
            </div>

            <div class="cell c-images">
                <img src="${item.pic}" alt="${item.goodsName}" >
            </div>

            <div class="cell c-goodsname">${item.goodsName}</div>
            <div class="cell c-price">
                <span>￥</span>
                <div class="c-price_num">${item.unitPrice}</div>
            </div>
            <div class="cell c-quantity">
                <input type="text" value="${item.quantity}" class="text_num" disabled>
            </div>
            <div class="cell c-sum">
                <span>￥</span>
                <div class="c-sum_num">${item.unitPrice * item.quantity}</div>
            </div>
            <div class="cell c-action">
                <a href="RemoveFromCart?goods_id=${item.goodsId}" class="remove">移除商品</a>
            </div>
        </div>
    </c:forEach>
</div>
<div class="payment">
    <div class="cart-pay">
        <div class="pay-left">
            <div class="select_all">
                <input type="checkbox" class="all each">
                全选
            </div>
            <div class="goods_num">
                已选择数量:
                <span>0</span>
                件
            </div>
        </div>
        <div class="pay-right">
            <div class="right_jie">
                <form action="settleAccount" method="post">
                    <button type="submit" class="settle-btn">结算</button> <!-- 添加了一个class用于CSS样式 -->
                </form>
                <div class="price-sum">
                    <div class="price-show">总价是：</div>
                    <div class="show-money">
                        ￥
                        <span>00.00</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(".remove").click(function(e){
        e.preventDefault();
        var url = $(this).attr("href");
        if(confirm("确定要移除该商品吗？")){
            window.location.href = url;
        }
    });
</script>
</body>
</html>